<?php
include_once('includes.php'); 
include_once('includes/rating.class.php');	

if(isset($_GET["id"]) && $_GET["id"]>0 )
{
	$id = (int) $_GET["id"];
	$sql = "select  highlights.id as hid, highlights.* ,matchs.*, competition.name as cname, competition.id as cid, competition.classicon as cicon from   highlights left join matchs on highlights.match_id = matchs.id left join competition on matchs.competition_id = competition.id where  status=2  and matchs.id=".addslashes($id);
	$match=db_fetch_one($sql);
	if(!$match)
	{
		Header("Location: /");
		exit;
	}
	
	
}	
else
{
	Header("Location: /");
	exit;
}

$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
list($team1, $team2 ) = split('-',$match->versus);
$team1 = trim($team1);
$team2 = trim($team2);


//-------------------------------------------
$page_title =  $team1." ".$match->score." ".$team2." (".formatOutputDate($local_kick_off).")";

$team1_info = db_fetch_one("SELECT * 
							FROM team_info 
							WHERE name in (	SELECT namphan 
											FROM team_name_matching 
											WHERE luanvo = '$team1')");
$team2_info = db_fetch_one("SELECT * 
							FROM team_info 
							WHERE name in (	SELECT namphan 
											FROM team_name_matching 
											WHERE luanvo = '$team2')");
?>

<?php include_once('includes/header.php'); 	 ?>


<span class="match-competition <?php echo $match->cicon; ?>"><a href="/competition/<?php echo $match->cid."-".clean_entities($match->cname);?>" title="<?php echo $match->cname;?>"><?php echo $match->cname;?></a></span> 
<h1 class="header">
<?php
if($team1_info != null)
{
?>
<a id="player_<?php echo str_replace(" ","_",trim($team1)); ?>" href="/team-info/<?php echo $match->team1_id . "-" . str_replace(" ","-",trim($team1)); ?>" onmouseover="show_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>&quot;);" onmouseout="hide_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>&quot;);">
	<?php echo $team1; ?>
</a>
<div class="xtip" id="player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="visibility: hidden;">
	<div class="ballon">
		<div class="tla" id="tla_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: inline;">
		</div>
		<div class="tra" id="tra_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: none;">
		</div>
		<div id="balloonBody">
			<h4>
			</h4>
			<div class="boxBody">
				<?php echo $team1_info->html; ?>
			</div>
			<div class="boxFooter">
				<p>
				</p>
			</div>
		</div>
		<div class="bla" id="bla_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: none;">
		</div>
		<div class="bra" id="bra_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: none;">
		</div>
	</div>
</div>
<?php
}
else
{
	echo $team1;
}
echo " $match->score ";
if($team2_info != null)
{
?>
<a id="player_<?php echo str_replace(" ","_",trim($team2)); ?>" href="/team-info/<?php echo $match->team2_id . "-" . str_replace(" ","-",trim($team2)); ?>" onmouseover="show_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>&quot;);" onmouseout="hide_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>&quot;);">
	<?php echo $team2; ?>
</a>
<div class="xtip" id="player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="visibility: hidden;">
	<div class="ballon">
		<div class="tla" id="tla_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: inline;">
		</div>
		<div class="tra" id="tra_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: none;">
		</div>
		<div id="balloonBody">
			<h4>
			</h4>
			<div class="boxBody">
				<?php echo $team2_info->html; ?>
			</div>
			<div class="boxFooter">
				<p>
				</p>
			</div>
		</div>
		<div class="bla" id="bla_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: none;">
		</div>
		<div class="bra" id="bra_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: none;">
		</div>
 	</div>
</div>
<?php
}
else
{
	echo $team2;
}
?>
</h1>

<span class="match-kickoff"><?php echo formatOutputDate($local_kick_off); ?></span> <br/>


<div style="padding:10px 0">
	<!-- AddThis Button BEGIN -->
	<div class="addthis_toolbox addthis_default_style ">
		<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
		<a class="addthis_button_tweet"></a>
		<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>	
	</div>
	<script type="text/javascript" src="/js/addthis_widget.js"></script>
	<!-- AddThis Button END -->
</div>

<div class="clearfix">
	<?php echo $match->content;?>
</div>

<div class="social-share">
	<span class="text">Chia sẻ</span>
	<!-- AddThis Button BEGIN -->
	<div class="content">
		<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
			<a class="addthis_button_facebook"></a>
			<a class="addthis_button_google"></a>
			<a class="addthis_button_twitter"></a>
			<a class="addthis_button_compact"></a>
			<a class="addthis_counter addthis_bubble_style"></a>
		</div>
	</div>
	<!-- AddThis Button END -->
</div>

<?php
$sql = "select  highlights.id as hid, highlights.* ,matchs.*, competition.name as cname, competition.id as cid, competition.classicon as cicon from   highlights left join matchs on highlights.match_id = matchs.id left join competition on matchs.competition_id = competition.id where  status=2 and matchs.id<>".$match->id." order by matchs.kick_off desc limit 10 ";
$matchs=db_fetch_all($sql);

if(count($matchs)>0) 
{
?>

<div class="cbox clearfix">
	<span class="title">Video bàn thắng</span>
	<div class="content">
		<ul class="matchs">
	<?php 
	foreach($matchs as $match)
	{
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
	
		list($team1, $team2 ) = split('-',$match->versus);
		$team1 = trim($team1);
		$team2 = trim($team2);
	?>
		<li class="<?php echo $match->cicon; ?>"> 
			<div class="cname"><?php echo $match->cname; ?></div>
			<div class="kick-off"><?php echo formatOutputDate($local_kick_off); ?></div>
			<div class="vs">	<a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>"><strong><?php echo $team1." ".$match->score." ".$team2;?></strong></a>  </div>
			
		</li>
	<?php
	}
	?>
		</ul>
		
	</div>
</div>
<?php
}
?>


<?php include_once('includes/footer.php'); 	 ?>